package com.labi.designpattern.service;

import com.labi.designpattern.enums.OrderEvent;
import org.springframework.messaging.Message;
import org.springframework.statemachine.annotation.OnTransition;
import org.springframework.statemachine.annotation.WithStateMachine;
import org.springframework.stereotype.Component;

@Component
//@WithStateMachine(name = "orderStateMachine2")  //这样就无法监听了 因为和定义的对应不上
@WithStateMachine(name = "orderStateMachine")  //这样 可以监听  ,名字对上了
//@WithStateMachine  //如果只有一个 状态机,  这样也可以监听
//public class OrderStateListener extends StateMachineListenerAdapter<OrderState,OrderEvent> {
public class OrderStateListenerV1 {

    @OnTransition(source = "CREATED", target = "WAIT_CHECKED")
    public void onPayStart(Message<OrderEvent> message) {
        System.out.println("开始处理支付请求: {}");
    }
}
